package com.mobileduty.pages;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.andoridtools.utils.SPUtils;
import com.mobileduty.R;
import com.mobileduty.comm.Constants;

import java.util.Timer;
import java.util.TimerTask;

/**
 * 欢迎页面
 */
public class WelcomeActivity extends AppCompatActivity {
    private Context context = this;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome_main);

        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                nextPage();
            }
        }, 2000);
    }

    public void nextPage() {
        boolean isFirstOpen = (boolean) SPUtils.get(context, Constants.FIRSTOPEN, true);
        if (isFirstOpen) {
            startActivity(new Intent(context, GuideActivity.class));
        } else {
            startActivity(new Intent(context, LoginActivity.class));
        }
        finish();
    }
}
